<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>
        人员信息编辑
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/main.css" media="all">


</head>
<body>

<div class="x-body">
    <form enctype="multipart/form-data" class="layui-form layui-form-pane" action="${pageContext.request.contextPath}/personnel/edit" id="add" method="post">
        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
            <div class="layui-tab-content" >
                <div class="layui-tab-item layui-show">
                    <!--<form class="layui-form layui-form-pane" action="" id="add">-->
                    <input hidden name="id" value="${personnel.id}">
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>所属房产
                        </label>
                        <div class="layui-input-inline">
                            <select name="bid" id="home_id">
                                <c:forEach items="${buildings}" var="b">
                                    <option <c:if test="${buildings1.id==b.buildings.id}">selected</c:if>value="${b.buildings.id}" >${b.buildings.remark}</option>
                                </c:forEach>


                            </select>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>成员名称
                        </label>
                        <div class="layui-input-inline">
                            <input type="text" name="name" autocomplete="off" placeholder="输入成员名称"
                                   class="layui-input" lay-verify="required" lay-reqtext="成员名称是必填项，岂能为空？" value="${personnel.name}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>身份证号
                        </label>
                        <div class="layui-input-inline">
                            <input type="text" name="peopleNum" autocomplete="off" placeholder="请输入身份证号码"
                                   class="layui-input" maxlength="18" lay-verify="identity" value="${personnel.peopleNum}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>出生日期
                        </label>

                        <div class="layui-input-inline">

                            <input class="layui-input" name="birthday" placeholder="出生日期" id="LAY_demorange_s" value="<fmt:formatDate pattern="yyyy-MM-dd" value="${personnel.birthday}"/>" >
                        </div>

                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>联系方式
                        </label>
                        <div class="layui-input-inline">
                            <input type="text" name="contactWay" autocomplete="off" placeholder=""
                                   class="layui-input" maxlength="11" lay-verify="required|phone" value="${personnel.contactWay}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>职业
                        </label>
                        <div class="layui-input-inline">
                            <input type="text" name="occupation" autocomplete="off" placeholder=""
                                   class="layui-input" value="${personnel.occupation}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>性别
                        </label>
                        <div class="layui-input-inline">
                            <input type="radio" name="sex" value="1" <c:if test="${personnel.sex}">checked</c:if> title="男" >
                            <div class="layui-unselect layui-form-radio layui-form-radioed"><i class="layui-anim layui-icon layui-anim-scaleSpring"></i>
                                <div>男</div>
                            </div>
                            <input type="radio" name="sex" value="0"  <c:if test="${!personnel.sex}">checked</c:if> title="女">
                            <div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i>
                                <div>女</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>成员类型
                        </label>
                        <div class="layui-input-inline">
                            <input type="radio" name="mtypeid" value="1" title="业主" <c:if test="${personnel.mtypeid==1}">checked</c:if>>
                            <div class="layui-unselect layui-form-radio layui-form-radioed"><i class="layui-anim layui-icon layui-anim-scaleSpring"></i>
                                <div>业主</div>
                            </div>
                            <input type="radio" name="mtypeid" value="2" title="家庭成员" <c:if test="${personnel.mtypeid==2}">checked</c:if>>
                            <div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i>
                                <div>家庭成员</div>
                            </div>
                            <input type="radio" name="mtypeid" value="3" title="租户"<c:if test="${personnel.mtypeid==3}">checked</c:if>>
                            <div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i>
                                <div>租户</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>成员照片
                        </label>
                        <input type="file" id="previewImg" name="headerFile" value="${pageContext.request.contextPath}/images/${personnel.img}">
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>状态
                        </label>
                        <div class="layui-input-inline">
                            <input type="radio" name="state" value="1" <c:if test="${personnel.state}">checked</c:if> title="可用" >
                            <div class="layui-unselect layui-form-radio layui-form-radioed"><i class="layui-anim layui-icon layui-anim-scaleSpring"></i>
                                <div>可用</div>
                            </div>
                            <input type="radio" name="state" value="0"  <c:if test="${!personnel.state}">checked</c:if> title="禁用">
                            <div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i>
                                <div>禁用</div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">
                            <span class='x-red'>*</span>描述
                        </label>
                        <div class="layui-input-block">
                            <input value="${personnel.remark}"name="remark" type="text" class="layui-textarea"></input>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <button class="layui-btn" type="submit" lay-filter="add" lay-submit="">
                            保存
                        </button>
                    </div>
                    <!--</form>-->
                    <div style="height:100px;"></div>
                </div>



            </div>

        </div>
    </form>
</div>
<script src="${pageContext.request.contextPath}/lib/layui/layui.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath}/js/x-layui.js" charset="utf-8"></script>
<script>
    layui.use(['laydate','element','layer','form'], function() {
        $ = layui.jquery;//jquery
        lement = layui.element();//面包导航
        layer = layui.layer;//弹出层
        form = layui.form();
        laydate = layui.laydate;//日期插件

        form.render();
        var start = {
            min: laydate.now()
            , max: '2099-06-16 23:59:59'
            , istoday: false
            , choose: function (datas) {
                //end.min = datas; //开始日选好后，重置结束日的最小日期
                //end.start = datas //将结束日的初始值设定为开始日
            }
        };
        document.getElementById('LAY_demorange_s').onclick = function () {
            start.elem = this;
            laydate(start);
        };

        form.on('select(aihao)', function (data) {
            communidy();
        });
        $(function () {
            communidy();
        });

//communidy();
        function communidy() {
            var communidy = $("#community_id").val();
            $.ajax({
                url: "xxx",
                type: "post",
                dataType: "json",
                data: {communidy: communidy},
                success: function (data) {
//console.log(data);
                    var dlen = data.length;
                    var str = '';
                    for (var i = 0; i < dlen; i++) {
                        var dt = data[i];
                        str += '<option value="' + dt.id + '">';
                        str += dt.home_name;
                        str += '</option>';
                    }

                    $("#home_id").html(str);
                    form.render('select', 'aihao');
//form.render('#building_id');

                }
            })
        }
    })
</script>



</body>
</html>